using System;

public static class CollisionHandlerFactory
{
	public enum CollisionType
	{
		CollideWithTable = 0,
		CollideWithNet = 1
	}

	public static CollisionHandlerBase GetCollisionHandler(CollisionType type)
	{
		switch ((int)type)
		{
		case 0:
			return TableCollisionHandler.instance;
		case 1:
			return NetCollisionHandler.instance;
		default:
			return null;
		}
	}

	public static FlightParams GetBallFlightParamsAfterBounce(CollisionType collisionType, FlightParams paramsBeforeBounce, float mass, float ballRadius)
	{
		CollisionHandlerBase.CollisionBallParams initialParams = default(CollisionHandlerBase.CollisionBallParams);
		initialParams.angularVelocity = paramsBeforeBounce.angularVelocity.GetReverseHandedVector() * 2f * (float)Math.PI;
		initialParams.velocity = paramsBeforeBounce.velocity;
		initialParams.position = paramsBeforeBounce.position;
		CollisionHandlerBase.CollisionBallParams collisionBallParams = GetCollisionHandler(collisionType).MotionParamsAfterCollision(initialParams, mass, ballRadius);
		FlightParams result = default(FlightParams);
		result.position = collisionBallParams.position;
		result.velocity = collisionBallParams.velocity;
		result.angularVelocity = collisionBallParams.angularVelocity.GetReverseHandedVector() / ((float)Math.PI * 2f);
		result.optionalNormal = collisionBallParams.optionalNormal;
		return result;
	}
}
